home *** CD-ROM | disk | FTP | other *** search
- Path: castle.nando.net!news
- From: Caius Martius <caius@nando.net>
- Newsgroups: comp.lang.c++
- Subject: Re: Why does this work?
- Date: Wed, 27 Mar 1996 17:21:33 -0800
- Organization: Carolantic Realty, Inc.
- Message-ID: <3159E99D.712B@nando.net>
- References: <DoxvnA.L0C@mail.auburn.edu>
- NNTP-Posting-Host: vyger1215.nando.net
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.0 (Win95; I; 16bit)
-
- John M. Greer wrote:
- >
- > This is probably a horribly simple question, but I was going through a
- > few books, brushing up on my iostreams, when I saw this tidbit in Jamsa's
- > Multimedia Trilogy (The CD-ROM by Kris Jamsa)
- >
- > #include <iostream.h>
- > #include <ctype.h>
- >
- > void main(void)
- > {
- > char letter;
- >
- > while (! cin.eof())
- > {
- > letter = cin.get();
- > letter = toupper(letter);
- > cout << letter;
- > }
- > }
- >
- > Why does this work!?!? It seems to reserve storage for only one
- > character in letter, but outputs a whole line at a time. Feel free to
- > flame my stupidity, but please satisfy my curiosity (I'm really not this
- > clueless, I promise!!)
- >
- > John Greer
-
- Actually, it is only storing, converting, and then displaying ONE
- character at a time. It does this so fast that it gives the illusion
- that a whole line is being outputed.
-
- Use a debugger to step through the program and you will see what I am
- talking about.
-
- Cheers,
-
- Caius
-